package com.hezuti.sns.dao;


import org.springframework.stereotype.Component;

import com.hezuti.common.dao.BaseHibernateDaoGeneric;
import com.hezuti.sns.domain.Product;

@Component
public class ProductDao extends  BaseHibernateDaoGeneric<Product>{
	/**
	 * 修改产品的属性
	 * @param p
	 * @return
	 */
	public Product modifyProduct(Product p){
		return this.merge(Product.class, p,Product.FIELD_PID);
	}
	/**
	 * 删除产品
	 * @param pid
	 * @return
	 * 	成功：1；失败-1
	 */
	public int deleteProduct(int pid){
		Product p = this.findUniqueBy(Product.FIELD_PID, pid);
		if(p==null)
			return -1;
		this.deleteById(pid);
		return 1;
	}
	/**
	 * 添加产品
	 * @param p
	 * @return
	 */
	public Product addProduct(Product p){
		return this.save(p);
	}
	
}
